package com.queclink.ycm.common.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * @author jim.li
 * @email jim.li@queclink.com
 * @date 2022-01-10 09:25:00
 */
public class UtcTimeUtils {

    public static Date getUtcTime() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date newTime = null;
        try {
            Date date = new Date(System.currentTimeMillis());
            System.out.println("时间 Date" + date);
            System.out.println("系统时间String：" + simpleDateFormat.format(date));
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT-0"));
            String utc = simpleDateFormat.format(date);
            System.out.println("utc时间String:" + utc);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            newTime = format.parse(utc);
            System.out.println("转换以后的时间Date：" + newTime);
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return newTime;
    }
}
